﻿#region
/* ===============================================
 * 作者：guopeng           时间：2012/2/4 10:50:30
 * 
 * 
 * 类描述：职位信息
 * 一张招募单可以对应多个招募职位信息
 * 
 * =============================================== */
#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;
using ueEngine.Biz.Inf.Entities.DBSupport;
using ueEngine.Framework.Exception;

namespace ueEngine.Biz.Inf.Entities
{
    [Table("Position")]
    public class Position : BaseEntity<Position>
    {
        public Position() { }
        public override Position Get(System.Linq.Expressions.Expression<Func<Position, bool>> where)
        {
            using (Context ctx = new Context())
            {
                var item = ctx.Position.FirstOrDefault(where);
                if (item != null)
                {
                    this.Id = item.Id;
                    this.IsIndex = item.IsIndex;
                    this.MaxSalary = item.MaxSalary;
                    this.MinSalary = item.MinSalary;
                    this.OperatorName = item.OperatorName;
                    this.Period = item.Period;
                    this.RecruitId = item.RecruitId;
                    this.ScanTime = item.ScanTime;
                    this.Trusteeship = item.Trusteeship;
                    this.Vacancy = item.Vacancy;
                    this.Degree = item.Degree;
                    this.Experienced = item.Experienced;
                    this.Gender = item.Gender;
                    this.PositionName = item.PositionName;
                    this.PositionDescript = item.PositionDescript;
                    this.PositionType = item.PositionType;
                    this.PositionPriority = item.PositionPriority;
                    this.PositionLevel = item.PositionLevel;
                    return this;
                }
                return null;
            }
        }
        #region Fileds
        [Column(TypeName="int")]
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }

        /// <summary>
        /// 招募单id
        /// </summary>
        [Column(TypeName="int")]
        [Required]
        public int RecruitId { get; set; }

        /// <summary>
        /// 招募标题
        /// </summary>
        [Column(TypeName = "nvarchar")]
        [StringLength(200)]
        [Required]
        public string PositionName { get; set; }

        /// <summary>
        /// 需求人数
        /// </summary>
        [Column(TypeName = "int")]
        public int Vacancy { get; set; }
        /// <summary>
        /// 职位类型
        /// </summary>
        [Column(TypeName = "int")]
        public int PositionType { get; set; }

        /// <summary>
        /// 预计支付最小薪资额（单位为元人民币）
        /// 薪资为 薪资额+薪资结算周期
        /// </summary>
        [Column(TypeName = "decimal")]
        public decimal MinSalary { get; set; }

        /// <summary>
        /// 预计支付最大薪资额（单位为元人民币）
        /// 薪资为 薪资额+薪资结算周期
        /// </summary>
        [Column(TypeName = "decimal")]
        public decimal MaxSalary { get; set; }

        /// <summary>
        /// 结算周期
        /// 160：小时 40：天 8：周 1：月
        /// </summary>
        [Column(TypeName = "int")]
        public int Period { get; set; }

        /// <summary>
        /// 性别要求 -1：不限 0：女 1：男
        /// </summary>
        [Column(TypeName = "int")]
        public int Gender { get; set; }
        /// <summary>
        /// 学位要求
        /// </summary>
        [Column(TypeName = "int")]
        public int Degree { get; set; }
        /// <summary>
        /// 是否要求有经验
        /// </summary>
        [Column(TypeName = "bit")]
        public bool Experienced { get; set; }
        /// <summary>
        /// 职位补充说明
        /// </summary>
        [Column(TypeName = "nvarchar")]
        public string PositionDescript { get; set; }
        /// <summary>
        /// 浏览次数
        /// </summary>
        [Column("ScanTime", TypeName = "int")]
        public int ScanTime { get; set; }

        /// <summary>
        /// 审核操作员
        /// </summary>
        [Column("OperatorName", TypeName = "nvarchar")]
        public string OperatorName { get; set; }

        /// <summary>
        /// 是否已经提交托管，且托管审核通过
        /// </summary>
        [Column("Trusteeship", TypeName = "bit")]
        public bool Trusteeship { get; set; }

        /// <summary>
        /// 是否已经被索引
        /// </summary>
        [Column("IsIndex", TypeName = "bit")]
        public bool IsIndex { get; set; }

        /// <summary>
        /// 职位级别
        /// </summary>
        [Column("PositionPriority",TypeName="int")]
        public int PositionPriority { get; set; }

        /// <summary>
        /// 兼职级别
        /// </summary>
        [Column(TypeName="int")]
        public int PositionLevel { get; set; }
        #endregion
    }

}
